(function() {

	var BibleClass = function() {
	};
	BibleClass.prototype = {
		init: function() {
		},
		getBible: function() {
			// TODO get bible data by ajax and display
			var list = [];
			for(var i = 0 ; i < list.length ; i++) {
				holybible.view.Bible.addBible(list[i]);
			}
		},
		getBibleList: function(callback) {
			$.ajax({
				url: "/data/versions",
				success: function(data) {
					var list = jQuery.parseJSON(data);
					if (callback) {
						callback(list);
					}
				}
			});
		}
	};
	holybible.model.Bible = new BibleClass();


	var BibleViewClass = function() {
	};
	BibleViewClass.prototype = {
		template: "<li><a href='/books?vcode=${bible.code}&vname=${bible.name}' title='${bible.name}'>${bible.name}</a></li>",
		box:null,
		init: function(id) {
			this.box = $("#" + id);
		},
		display: function(list) {
			for(var i = 0; i < list.length ; i++) {
				this.addBible(list[i]);
			}
		},
		addBible: function(bible) {
			if (bible) {
				this.box.append(this.makeHtml(bible));	
			}
		},
		makeHtml: function(bible) {
			var obj = TrimPath.parseTemplate(this.template);
			var html = obj.process({
					bible: bible
				});
			return html;
		}
	};
	holybible.view.Bible = new BibleViewClass();
	
	var BibleControllerClass = function() {
		this.model = holybible.model.Bible;
		this.view = holybible.view.Bible;
	};
	BibleControllerClass.prototype = {
		init: function(id) {
			this.view.init(id);
		},
		displayVersion: function() {
			var self = this;
			this.model.getBibleList(function(list) {
				self.view.display(list);
			});
		}
	};
	holybible.controller.Bible = new BibleControllerClass();


	var BookClass = function() {
	};
	BookClass.prototype = {
	};
	holybible.model.Book = new BookClass();

})();